package org.cboard.query;

import org.cboard.security.utils.SpringContextHolder;

import java.util.List;

/**
 * 参数值处理管理者入口
 */
public final class DyParamHandlerManager {

	public static String getValue(QueryParameter pp, String value) {
		if (!SpringContextHolder.getApplicationContext().containsBeanDefinition(pp.getFormElement())) {
			pp.setFormElement("defaultDyParamHandler");
		}
		DyParamHandler dy = SpringContextHolder.getBean(pp.getFormElement());
		return dy.getValue(pp, value);
	}

	public static List getSqlParamValue(QueryParameter pp, String[][] data){
		if(!"sql".equals(pp.getDataSource())){
			return null;
		}
		if (!SpringContextHolder.getApplicationContext().containsBeanDefinition(pp.getFormElement())) {
			pp.setFormElement("defaultDyParamHandler");
		}
		DyParamHandler dy = SpringContextHolder.getBean(pp.getFormElement());
		return dy.getSqlParamValue(data);
	}

}
